﻿@model IEnumerable<ApplicationUser>

@{
    ViewBag.Title = "用户列表";
}

<h1>所有用户</h1>

@if (Model.Any())
{
    <a asp-controller="Account" asp-action="Register" class="btn btn-primary mb-3" style="width: auto">创建用户</a>

    foreach (var item in Model)
    {
        <div class="card mb-3">
            <div class="card-header">用户Id：@item.Id</div>
            <div class="card-body">
                <h5 class="card-title">@item.UserName</h5>
            </div>
            <div class="card-footer">
                @*<button type="submit" class="btn btn-danger" onclick="return confirm('您确定要删除：@item.UserName 吗？')">删除</button>*@
                <form method="post" asp-action="DeleteUser" asp-route-id="@item.Id">
                    <a asp-controller="Admin" asp-action="EditUser" asp-route-id="@item.Id" class="btn btn-primary">编辑</a>
                    <span id="confirmDeleteSpan_@item.Id" style="display: none">
                        <span>你确定你要删除？</span>
                        <button type="submit" class="btn btn-danger">是</button>
                        <a href="#" class="btn btn-primary" onclick="confirmDelete('@item.Id',false)">否</a>
                    </span>
                    <span id="deleteSpan_@item.Id">
                        <a href="#" class="btn btn-danger" onclick="confirmDelete('@item.Id',true)">删除</a>
                    </span>
                </form>

                @*<a asp-controller="Admin" asp-action="DeleteUser" asp-route-id="@item.Id" class="btn btn-danger">删除</a>*@
            </div>
        </div>
    }

}
else
{
    <div class=" card">
        <div class="card-header">
            尚未创建用户
        </div>
        <div class="card-body">
            <h5>点击下方按钮创建用户</h5>
            <a asp-controller="Account" asp-action="Register" class="btn btn-primary">创建用户</a>
        </div>
    </div>
}

@section Scripts
{
    <script src="~/js/CustomScripts.js" asp-append-version="true"></script>
}
